<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        {{getTemp}}
        <div>{{aPlus}}</div>
        <button @click="fn()">修改</button>
    </div>
</body>
<script src="js/vue.js"></script>
<script>
    let vm = new Vue({
        el:"#app",
        data:{
            a:10
        },
        computed:{
            // 计算属性 
            getTemp(){
                return this.a * 2
            },
            // 读取和设置
            aPlus:{
                get(){
                    console.log(1);
                    return this.a -2
                },
                // 当aplus发生改变的时候 才执行set()  先执行set 再执行get
                set(v){
                    this.a = v -5
                    console.log(2);
                }
            }
        },
        methods:{
            fn(){
                this.aPlus = 20
            }
        }
    })
</script>
</html>